package com.demo;

import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;

public class SafeVarargsDemo {

//  @SafeVarargs
  //去掉该方法会出现编译信息未检查类型信息
  static void safeVarargsDemo(List<String>... stringLists) {
    Object[] array = stringLists;
    List<Integer> tmpList = Arrays.asList(42);
    //这个时候array[0]由原来的
    array[0] = tmpList; // Semantically invalid, but compiles without warnings
    String s = stringLists[0].get(0); // Oh no, ClassCastException at runtime!
    System.out.println(s);
  }


  @Test
  public void testSaveVarags() {
    safeVarargsDemo(Arrays.asList(""));
  }


}
